<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{$appConfigs.title}</title>

    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/themes/{$page_theme | default: 'default'}/easyui.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/easyui/themes/icon.css">
    <link rel="stylesheet" type="text/css" href="{$contextPath}/pas/style/my.css">
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="{$contextPath}/pas/javascript/my.js"></script>
    
</head> 
<body onpageshow="resetPagination2('dg')">
    {datagrid id="dg" datasource="/invest/AssetsService/findAll4.do" template="common/datagrid3.tpl" view="i_assets.price_view"}
    {form id="dlg2" view="i_assets_price" }
    
    <script>
    field_formatters.risk_level=function (value, row, index){
		if(value == 4)
			return '<font color="red">高</font>';
		else if(value == 3)
			return '<font color="red">中高</font>';
		else if(value == 2)
			return '<font color="orange">中</font>';
		else if(value == 1)
			return '<font color="green">低</font>';
		else if(value == 0)
			return '安全';
    }
    field_formatters.status=function (value, row, index){
		if(value == 1)
			return '<font color="green">在用</font>';
		else 
			return '<font color="red">不在用</font>';
    }
    field_formatters.fellRateM3=function (value, row, index){
		if(value) {
			return '<font color="green">'+numberFormat(value,2)+'%</font>';
		}
    }
    field_formatters.riseRateM3=function (value, row, index){
		if(value) {
			return '<font color="red">'+numberFormat(value,2)+'%</font>';
		}
    }
    field_formatters.fellRateM6=function (value, row, index){
		if(value) {
			return '<font color="green">'+numberFormat(value,2)+'%</font>';
		}
    }
    field_formatters.riseRateM6=function (value, row, index){
		if(value) {
			return '<font color="red">'+numberFormat(value,2)+'%</font>';
		}
    }
    field_formatters.fellRateM12=function (value, row, index){
		if(value) {
			return '<font color="green">'+numberFormat(value,2)+'%</font>';
		}
    }
    field_formatters.riseRateM12=function (value, row, index){
		if(value) {
			return '<font color="red">'+numberFormat(value,2)+'%</font>';
		}
    }
    
    function fetchPrice() {
    	$.messager.confirm('操作确认！','正准备重新抓取指数价格，可能时间较长！',function(r){
			$('#js-waiting').show();
			$.getJSON('/assets/AssetsPriceCaptureService/catchAllAssetsPrice.do', function(data){
				$('#js-waiting').hide();
				$.messager.show({
                    title: '提示',
                    msg: '价格抓取完成！'
                });
			});
        });
    }
    
    function showPriceDetail() {
	    var row = getDatagrid('dg').datagrid('getSelected');
	    if(row) {
	    	window.parent.openTab(row.name + '的价格','/invest/assets/assets_price.shtml?assets_id='+row.assets_id);
	    } else {
			alert('没有选择投资计划！');
	    }
    }

	function showPriceChart() {
	    var row = getDatagrid('dg').datagrid('getSelected');
	    if(row) {
			var dt = new Date();
			dt.setMonth( dt.getMonth()- 12);
			var ds = date_formatter(dt);
	    	window.parent.openTab(row.name + '的价格图','/invest/assets/assets_price_chart.shtml?assets_id='+row.assets_id+"&from_date="+ds+"&name="+row.name);
	    } else {
			alert('没有选择投资计划！');
	    }
	}
	{literal}
	function resetPagination2(dg){
		if(!dg) dg = 'dg';
		var p = getDatagrid(dg).datagrid('getPager');
		$(p).pagination({             
			pageSize: 15,           
			pageList: [15,30,100],
			beforePageText: '第',      
			afterPageText: '页    共 {pages} 页',             
			displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录'                  
		}); 
	}
	{/literal}
    </script>
</body>
</html>